use tauri::command;
use crate::ctp_commands::ctp::validation::{validate_order, ValidationResult};
use crate::ctp_commands::ctp::types::{OrderRequest, WindowContext};

/// Tauri命令：验证订单
#[command]
pub async fn validate_order_request(
    session_id: String,
    order: OrderRequest,
    window_context: Option<WindowContext>,
) -> ValidationResult {
    println!("🔍 [VALIDATION] 开始验证订单: {:?}", order);
    
    let result = validate_order(&session_id, &order).await;
    
    if result.is_valid {
        println!("✅ [VALIDATION] 订单验证通过");
    } else {
        println!("❌ [VALIDATION] 订单验证失败: {} 个错误", result.errors.len());
        for (i, error) in result.errors.iter().enumerate() {
            println!("  {}. [{}] {}", i + 1, error.error_type, error.message);
        }
    }
    
    result
}
